package com.crm.jdy.service.usermanager;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.crm.jdy.common.mapper.WxMapper;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service(version = "${service.version}")
@Component
public class WxServiceImpl  extends ServiceImpl<WxMapper, Object> implements WxService  {

//   @Autowired
//   WxMpService wxMpService;
//
//    @Override
//    public void sentMessages() {
//
//        RestTemplate restTemplate=new RestTemplate();
//        Map<String,String> params=new HashMap<>();
//        params.put("appid","wxaeda779a371ee311");
//        params.put("secret","07a52865d2ce2640a167f8d7378c1da7");
//        ResponseEntity<Object> responseEntity = restTemplate.getForEntity("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={appid}&secret={secret}",Object.class,params);
//        System.out.println(responseEntity);
//        System.out.println("==================");
//        WxMpTemplateMessage templateMessage = new WxMpTemplateMessage();
//        System.out.println("==========----========");
//        templateMessage.setTemplateId("QHZWiYSdF7IdbFtM_c9KroEmSjRYPXuPv4-LFVhQh0Y");
//        templateMessage.setToUser("oVHFO6bJn6TwOLVlF-1_s0H86Mx0");
//        System.out.println("===2222222222222=======");
//        //点餐模板   1911682064    oh3hV0vxuYVBgUk_UA7YUYN_hS6U
////        List<WxMpTemplateData> data = Arrays.asList(
////                new WxMpTemplateData("first", "亲，请记得收货。"),
////                new WxMpTemplateData("keyword", "xinxi"),
////                new WxMpTemplateData("keyword1", "2020-12-02"),
////                new WxMpTemplateData("remark", "欢迎再次光临！")
////        );
//        List<WxMpTemplateData> data = new ArrayList();
//        data.add( new WxMpTemplateData("first", "亲，请记得收货。"));
//        data.add( new WxMpTemplateData("keyword", "xinxi"));
//        data.add( new WxMpTemplateData("keyword1", "2020-12-02"));
//        data.add( new WxMpTemplateData("remark", "亲，欢迎再次光临。"));
//        System.out.println("======333344444==========");
//        templateMessage.setData(data);
//        System.out.println("=======555555555=======");
//        try {
//            System.out.println("======888888888=====");
//            wxMpService.getTemplateMsgService().sendTemplateMsg(templateMessage);
//        }catch ( Exception e) {
//            log.error("【微信模版消息】发送失败, {}", e);
//        }
//    }
}
